package psn.kiko.config.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 处理器拦截器，还需要添加到拦截器列表才生效 2024/12/2 22:41
 */
@Component
@Slf4j
public class HandlerRecordInterceptor implements HandlerInterceptor{
	@Override
	public boolean preHandle(HttpServletRequest req,HttpServletResponse resp,Object handler){
		if(handler instanceof HandlerMethod){
			HandlerMethod hm = (HandlerMethod) handler;
			log.info("intercepting: {}.{}({})",hm.getBeanType().getCanonicalName(),
					hm.getMethod().getName(),req.getServletPath());
		}
		return true;
	}
}
